import js from '@eslint/js'
import globals from 'globals'
import tseslint from 'typescript-eslint'
import pluginVue from 'eslint-plugin-vue'
import { defineConfig } from 'eslint/config'


export default defineConfig([
  tseslint.configs.recommended,
  pluginVue.configs['flat/essential'],
  { 
    files: ['**/*.{js,mjs,cjs,ts,vue}'],
    plugins: { js }, 
    extends: ['js/recommended'],
    rules: {
      // ====== 这里是统一的代码风格规则 ======
      indent: ['error', 2],            // 强制 2 空格缩进
      'vue/html-indent': ['error', 2], // Vue模板里也2空格缩进
      semi: ['error', 'never'],                                   // 禁止分号
      quotes: ['error', 'single',{ allowTemplateLiterals: true }],// 强制单引号或模板字符串
    },
    ignores: ['dist','node_modules','*.json','*.png','*.jpg','*.svg']
  },
  { files: ['**/*.{js,mjs,cjs,ts,vue}'], languageOptions: { globals: globals.browser } },
  { files: ['**/*.vue'], languageOptions: { parserOptions: { parser: tseslint.parser } } },
])